package android.tusnotas.util;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.tusnotas.activities.Login;
import android.tusnotas.activities.R;
import android.tusnotas.model.TusNotasModel;
import android.util.Log;

public class AlertBuilder {
	
	public static void showAlert(Context context, String title, int msg){
		Builder builder=new AlertDialog.Builder(context);
		builder.setTitle(title);
		builder.setNeutralButton(context.getResources().getString(R.string.button_close), new DialogInterface.OnClickListener() {
	           public void onClick(DialogInterface dialog, int id) {
	                dialog.cancel();
	           }
	    });
		if (msg != -1){
			builder.setMessage(msg);
		}
		builder.show();
	}
	
	public static void showAlert(Context context, int title, int msg){
		showAlert(context, context.getResources().getString(title), msg);
	}
	
	public static void showError(Context context, int msg){
		showAlert(context, context.getResources().getString(R.string.alert_title_error), msg);
	}
	
	public static void showWarning(Context context, int msg){
		showAlert(context, context.getResources().getString(R.string.alert_title_warning), msg);
	}
	
	public static void showUsageInfo(Context context) {
		showAlert(context, "", R.string.alert_message_usage);
	}

	
	public static void showAboutInfo(Context context) {
		showAlert(context, "", R.string.alert_message_about);
	}
	
	public static void logout(Context context) {
		
		Intent intent = new Intent("kill");
		context.sendBroadcast(intent);
		
		Intent showLogin =  new Intent(context, Login.class);
		context.startActivity(showLogin);
	}

}
